 

package com.zdkj.subway.support.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zdkj.common.core.util.R;
import com.zdkj.common.log.annotation.SysLog;
import com.zdkj.subway.support.entity.SwPmStationPersonGuardRecord;
import com.zdkj.subway.support.service.SwPmStationPersonGuardRecordService;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;


/**
 * 车站人员在岗记录表
 *
 * @author cuilei
 * @date 2020-06-04 10:30:33
 */
@RestController
@AllArgsConstructor
@RequestMapping("/swpmstationpersonguardrecord" )
@Api(value = "swpmstationpersonguardrecord", tags = "车站人员在岗记录表管理")
public class SwPmStationPersonGuardRecordController {

    private final  SwPmStationPersonGuardRecordService swPmStationPersonGuardRecordService;

    /**
     * 分页查询
     * @param page 分页对象
     * @param swPmStationPersonGuardRecord 车站人员在岗记录表
     * @return
     */
    @ApiOperation(value = "分页查询", notes = "分页查询")
    @GetMapping("/page" )
    public R getSwPmStationPersonGuardRecordPage(Page page, SwPmStationPersonGuardRecord swPmStationPersonGuardRecord) {
        return R.ok(swPmStationPersonGuardRecordService.page(page, Wrappers.query(swPmStationPersonGuardRecord)));
    }


    /**
     * 通过id查询车站人员在岗记录表
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id查询", notes = "通过id查询")
    @GetMapping("/{id}" )
    public R getById(@PathVariable("id" ) Integer id) {
        return R.ok(swPmStationPersonGuardRecordService.getById(id));
    }

    /**
     * 新增车站人员在岗记录表
     * @param swPmStationPersonGuardRecord 车站人员在岗记录表
     * @return R
     */
    @ApiOperation(value = "新增车站人员在岗记录表", notes = "新增车站人员在岗记录表")
    @SysLog("新增车站人员在岗记录表" )
    @PostMapping
    @PreAuthorize("@pms.hasPermission('support_swpmstationpersonguardrecord_add')" )
    public R save(@RequestBody SwPmStationPersonGuardRecord swPmStationPersonGuardRecord) {
        return R.ok(swPmStationPersonGuardRecordService.save(swPmStationPersonGuardRecord));
    }

    /**
     * 修改车站人员在岗记录表
     * @param swPmStationPersonGuardRecord 车站人员在岗记录表
     * @return R
     */
    @ApiOperation(value = "修改车站人员在岗记录表", notes = "修改车站人员在岗记录表")
    @SysLog("修改车站人员在岗记录表" )
    @PutMapping
    @PreAuthorize("@pms.hasPermission('support_swpmstationpersonguardrecord_edit')" )
    public R updateById(@RequestBody SwPmStationPersonGuardRecord swPmStationPersonGuardRecord) {
        return R.ok(swPmStationPersonGuardRecordService.updateById(swPmStationPersonGuardRecord));
    }

    /**
     * 通过id删除车站人员在岗记录表
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id删除车站人员在岗记录表", notes = "通过id删除车站人员在岗记录表")
    @SysLog("通过id删除车站人员在岗记录表" )
    @DeleteMapping("/{id}" )
    @PreAuthorize("@pms.hasPermission('support_swpmstationpersonguardrecord_del')" )
    public R removeById(@PathVariable Integer id) {
        return R.ok(swPmStationPersonGuardRecordService.removeById(id));
    }

}
